package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pets.domain.Pets;
import com.ruoyi.pets.service.impl.PetsServiceImpl;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Date:2024/7/8
 * Author：顾雁影
 * Description:
 */
@RestController
@RequestMapping("/app/pet")
public class AppPetController {
    @Resource
    private PetsServiceImpl petsService;


    /**
     * 查询未出售售的宠物列表购物车
     */
    @GetMapping("/selectByStatues")
    public AjaxResult getPetsByStatus(){
        String petStatus = "未出售";
        List<Pets> petsList = petsService.selectPetsLisByStatue(petStatus);
        return AjaxResult.success(petsList);
    }

    @GetMapping("/selectById/{pet_Id}")
    public AjaxResult getPetsById(@PathVariable("pet_Id")long pet_Id){
        Pets Pet = petsService.selectPetsByPetId(pet_Id);
        return AjaxResult.success(Pet);
    }

    @GetMapping("/selectByType/{pet_type}")
    public AjaxResult getPetsByStatus(@PathVariable("pet_type")String pet_type){
        String status = "未出售";
        List<Pets> petsList = petsService.selectPetByType(status,pet_type);
        return AjaxResult.success(petsList);
    }
    /**
     * 修改宠物
     */
    @PutMapping("/updatePet")
    public AjaxResult edit(@RequestBody Pets pets)
    {
        return AjaxResult.success(petsService.updatePets(pets));
    }
}
